/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package apteka;

import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 *
 * @author Marek
 */
@Controller
@RequestMapping("/activate.htm")
public class ActivateUserController {

    @Autowired
        UserManager user_man;

    @RequestMapping(method = RequestMethod.GET)
    public String activate(@RequestParam String token, Map model) {
        String temp = user_man.activateUser(token);
        if (!temp.isEmpty()) {
            model.put("username", temp);
            return "activateUser";
        } else {
            return "redirect:index.htm";
        }
    }

}
